package toDo.app;

import java.util.List;

import toDo.app.models.MapLocation;
import toDo.app.models.ToDoListItem;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

import android.os.Bundle;

public class ToDoMapActivity extends MapActivity{
	private MapView view;
	private MapController mController;
	private ToDoListItem item;
	private MapLocation location;
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.map);
	    view = (MapView) findViewById(R.id.mapview);
	    mController = view.getController();
	    
	    view.setBuiltInZoomControls(true);
	    item = ToDoListItem.getItemFromIntent(getIntent());
	    
	    if(item != null && item.location != null){
	    	location = new MapLocation(this,item);
        	List<Overlay> listOfOverlays = view.getOverlays();
        	listOfOverlays.clear();
        	listOfOverlays.add(location);
        	mController.animateTo(location.getGeoPoint());
            mController.setZoom(17); 
	    }
        view.invalidate();
	}
	
	@Override
	protected boolean isRouteDisplayed() {
	    return false;
	}
}
